import { createI18n } from "vue-i18n";
import zh from "./zh.json";
import en from "./en.json";
import zhtw from "./zh-tw.json";
import vantZhCN from 'vant/lib/locale/lang/zh-CN';
import vantZhTW from 'vant/lib/locale/lang/zh-TW';
import vantEnUS from 'vant/lib/locale/lang/en-US';
import { localStorage } from "@/utils/local-storage";

const i18n: any = createI18n({
  locale: localStorage.get("lang") || "zhtw",
  legacy: false,
  globalInjection: true,
  messages: {
    zh: {
      ...zh,
      ...vantZhCN
    },
    zhtw: {
      ...zhtw,
      ...vantZhTW
    },
    en: {
      ...en,
      ...vantEnUS
    },
  }
});

export { i18n };
